package com.tanhua.server.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.server.mapper.UserInfoMapper;
import com.tanhua.server.mapper.UserMapper;
import com.tanhua.server.pojo.User;
import com.tanhua.server.pojo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Autowired
    private UserMapper userMapper;
    public IPage<UserInfo> queryFindUserInfo(Long page, Long pageSize, QueryWrapper<UserInfo> wrapper) {

        Page<UserInfo> userInfoPage=new Page<>(page,pageSize);

        IPage<UserInfo> userInfoIPage = userInfoMapper.selectPage(userInfoPage, wrapper);
        return userInfoIPage;
    }

    public UserInfo queryUserInfoById(Integer userId) {
        QueryWrapper<UserInfo> wrapper=new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        return userInfoMapper.selectOne(wrapper);
    }

    public User queryUserById(Long userId) {
        QueryWrapper<User> wrapper=new QueryWrapper<>();
        wrapper.eq("id",userId);
        return userMapper.selectOne(wrapper);
    }
}
